// 支付渠道
import { GetPaymentChannelList } from "@/request/paychannel"
import { useEffect, useState } from "react"

export default function usePayChannel () {
    const [ options, setOptions ] = useState<Array<Record<string,unknown>>>([])
    const getData = async () => {
        const { code, data } = await GetPaymentChannelList({
            limit: 1000,
            page: 1
        } as any)
        if ( code === 200 ) {
            setOptions( data?.list?.map((item: { id: any; channelName: any })=>{
                return {
                    ...item,
                    label: item.channelName,
                    value: item.id
                }
            }) )
        } else {
            setOptions( [] )
        }
    }
    useEffect( () => {
        getData()
    }, [] )
    return options
}